/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package TableDAO;

import eloma.classe.material.Material;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Icaro
 */
public class MaterialTableModel extends AbstractTableModel {

    private List<Material> listMaterial;
    private boolean ordenarPorNome = true;

    public MaterialTableModel(List<Material> listMaterial) {
        this.listMaterial = listMaterial;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Material material = listMaterial.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return material.getMaterial();
            case 1:
                return material.getPesoMetro() + " Kg/m";
        }
        return null;
    }

    @Override
    public int getRowCount() {
        return listMaterial.size();
    }

    @Override
    public int getColumnCount() {
        return 3;
    }

    public Material getValoresMaterial(int rowIndex) {
        return listMaterial.get(rowIndex);
    }

    public boolean isOrdenarPorNome() {
        return ordenarPorNome;
    }

    public void setOrdenarPorNome(boolean ordenarPorNome) {
        this.ordenarPorNome = ordenarPorNome;
    }

}
